package com.ujs.edu.medicine.dao;

import com.ujs.edu.medicine.dataobject.LiketableCommentUser;
import java.util.List;

import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;
@Mapper
public interface LiketableCommentUserMapper {
    @Delete({
        "delete from liketable_comment_user",
        "where liketableid = #{liketableid,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer liketableid);

    @Insert({
        "insert into liketable_comment_user (liketableid, commentId, ",
        "userId, createtime)",
        "values (#{liketableid,jdbcType=INTEGER}, #{commentid,jdbcType=INTEGER}, ",
        "#{userid,jdbcType=INTEGER}, now())"
    })
    int insert(LiketableCommentUser record);

    @Select({
        "select",
        "liketableid, commentId, userId, createtime",
        "from liketable_comment_user",
        "where liketableid = #{liketableid,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="liketableid", property="liketableid", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="commentId", property="commentid", jdbcType=JdbcType.INTEGER),
        @Result(column="userId", property="userid", jdbcType=JdbcType.INTEGER),
        @Result(column="createtime", property="createtime", jdbcType=JdbcType.TIMESTAMP)
    })
    LiketableCommentUser selectByPrimaryKey(Integer liketableid);

    @Select({
        "select",
        "liketableid, commentId, userId, createtime",
        "from liketable_comment_user"
    })
    @Results({
        @Result(column="liketableid", property="liketableid", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="commentId", property="commentid", jdbcType=JdbcType.INTEGER),
        @Result(column="userId", property="userid", jdbcType=JdbcType.INTEGER),
        @Result(column="createtime", property="createtime", jdbcType=JdbcType.TIMESTAMP)
    })
    List<LiketableCommentUser> selectAll();

    /*通过commentid获取点赞*/
    @Select("select * from liketable_comment_user where commentId=#{commentId}")
    List<LiketableCommentUser> selectBycommentId(@Param("commentId")Integer commentId);

    @Update({
        "update liketable_comment_user",
        "set commentId = #{commentid,jdbcType=INTEGER},",
          "userId = #{userid,jdbcType=INTEGER},",
        "where liketableid = #{liketableid,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(LiketableCommentUser record);
}